package com.meitianiot.module.smart.mqtt.handler;

import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
import com.github.tocrhz.mqtt.annotation.Payload;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Slf4j
@Component
public class TestMessageHandler {

    /**
     * topic = camera_001
     */
    @MqttSubscribe("camera_001")
    public void sub(String topic, MqttMessage message, @Payload String payload) {
        log.info("receive from    : {}", topic);
        log.info("message payload : {}", new String(message.getPayload(), StandardCharsets.UTF_8));
        log.info("string payload  : {}", payload);
    }

}
